package com.ocom.payconfig.controller;

import com.ocom.common.constant.PayConfigUrl;
import com.ocom.common.entity.payconfig.EntityOrderReplaceItem;
import com.ocom.common.request.payconfig.*;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import com.ocom.payconfig.service.OrderReplaceDataService;
import com.ocom.payconfig.service.OrderReplaceItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderReplaceItemController {


    @Autowired
    private OrderReplaceItemService orderReplaceItemService;


    @Autowired
    private OrderReplaceDataService orderReplaceDataService;

    /**
     * 代订餐项目查询
     * @return
     */
    @PostMapping(PayConfigUrl.URL_getOrderReplaceList)
    public Result getOrderReplaceList(@RequestBody GetOrderReplaceListRequest request){
        return this.orderReplaceItemService.getOrderReplaceList(request.getComId(),request);
    }
    /**
     * 代订餐项目新增
     * @return
     */
    @PostMapping(PayConfigUrl.URL_addOrderReplace)
    public Result addOrderReplace(@RequestBody EntityOrderReplaceItem orderReplaceItem){
        return this.orderReplaceItemService.addOrderReplace(orderReplaceItem.getComId(), orderReplaceItem);
    }

    /**
     * 代订餐项目修改
     * @return
     */
    @PostMapping(PayConfigUrl.URL_editOrderReplace)
    public Result editOrderReplace(@RequestBody EntityOrderReplaceItem orderReplaceItem){
        return this.orderReplaceItemService.editOrderReplace(orderReplaceItem.getComId(), orderReplaceItem);
    }

    /**
     * 启动代订餐项目
     * @return
     */
    @PostMapping(PayConfigUrl.URL_startOrderReplace)
    public Result startOrderReplace(@RequestBody StartOrderReplaceRequest request){
        return this.orderReplaceItemService.startOrderReplace(request.getComId(),request);
    }

    /**
     * 中止代订餐项目
     * @return
     */
    @PostMapping(PayConfigUrl.URL_pauseOrderReplace)
    public Result pauseOrderReplace(@RequestBody PauseOrderReplaceRequest request){
        return this.orderReplaceDataService.pauseOrderReplace(request.getComId(),request);
    }

    /**
     *
     * @return
     */
    public Result startOrderReplaceByJob(){
        return ResultUtil.success();
    }

    /**
     * 增加
     * @return
     */
    @PostMapping(PayConfigUrl.URL_addOrderReplaceByPerson)
    public Result addOrderReplaceByPerson(@RequestBody AddOrderReplaceByPersonRequest request){
        return this.orderReplaceDataService.addOrderReplaceByPerson(request.getComId(), request);
    }

    @PostMapping(PayConfigUrl.URL_removeOrderReplaceByPerson)
    public Result removeOrderReplaceByPerson(@RequestBody RemoveOrderReplaceByPersonRequest request){
        return this.orderReplaceDataService.removeOrderReplaceByPerson(request.getComId(), request);
    }
}
